package com.code.soulnetty.modbus.client.message;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * @author lyf
 * @date 2022-12-17 11:48
 */
@Setter
@Getter
@ToString
public class ProtocolResponse {

    private boolean success;
    private String errorMsg;
    private String msgId;

    public static ProtocolResponse fail(String msgId, String msg) {
        final ProtocolResponse response = new ProtocolResponse();
        response.setMsgId(msgId);
        response.setErrorMsg(msg);
        response.setSuccess(Boolean.FALSE);
        return response;
    }

    public static ProtocolResponse fail(String msg) {
        final ProtocolResponse response = new ProtocolResponse();
        response.setErrorMsg(msg);
        response.setSuccess(Boolean.FALSE);
        return response;
    }
}
